package com.example.security.config;

import com.example.security.interceptor.TokenInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 23050
 * @version 1.0
 * @description: 配置拦截器  用于更新jwt的过期时间
 * @date 2025/2/7 22:07
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Resource
    private TokenInterceptor tokenInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .excludePathPatterns("/**/login","/friend/user/sentCode")  //登录接口不拦截
                .addPathPatterns("/**"); //拦截其他所有接口
    }
}
